package multiple.thread.copy;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;

public class ReadFrom {
	private RandomAccessFile from;  
	
    public ReadFrom(String fromFile) throws FileNotFoundException  
    {  
        this.from=new RandomAccessFile(fromFile, "r");  
    }  
    //同步文件读取操作  
    synchronized public int read(byte[] buffer, long pos) throws IOException  
    {  
        from.seek(pos);  
        return from.read(buffer);  
    }  
    //关闭随机文件访问流，释放相关系统资源  
    public void close() throws IOException  
    {  
        from.close();  
    } 

}
